package com.bootdo.project.controller;
import com.bootdo.project.domain.TClass;
import com.bootdo.project.service.impl.TClassService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;
import com.codegen.vo.Result;
import com.codegen.vo.Page;

import java.util.List;

import org.apache.ibatis.annotations.Param;

/**
 *
 * Created by xxxx on 2019/03/19.
 */
@Controller
@RequestMapping("/tClass/")
public class TClassController {

    @Autowired
    TClassService tClassService;

    @RequestMapping("selectAll")
    @ResponseBody
    public Result<List<TClass>> selectAll(){
        return Result.success(tClassService.selectAll());
    }

    @RequestMapping("select")
    @ResponseBody
    public Result<TClass> selectByPrimaryKey(Integer id){
        return Result.success(tClassService.selectByPrimaryKey(id));
    }

    @RequestMapping("selectByCondition")
    @ResponseBody
    public Result<List<TClass>> selectByCondition(TClass record){
        return Result.success(tClassService.selectByCondition(record));
    }

    @RequestMapping("count")
    @ResponseBody
    public Result<Integer> count(TClass record){
        return Result.success(tClassService.count(record));
    }

    @RequestMapping("insert")
    @ResponseBody
    public Result<Integer> insertSelective(TClass record){
        return Result.success(tClassService.insertSelective(record));
    }

    @RequestMapping("update")
    @ResponseBody
    public Result<Integer> updateByPrimaryKeySelective(TClass record){
        return Result.success(tClassService.updateByPrimaryKeySelective(record));
    }

    @RequestMapping("selectByPage")
    @ResponseBody
    public Result<Page<List<TClass>>> selectByPage(Page<TClass> page){
        List<TClass> list = null;
        page = page.sequentialDisplayCalculate(tClassService.count(page.getObj()));
        if (page.getTotalCount() > 0) {
            list = tClassService.selectByPage(page);
        }
        Page<List<TClass>> result = new Page<List<TClass>>(page, list);
        return Result.success(result);
    }

    @RequestMapping("deleteByCondition")
    @ResponseBody
    public Result<Integer> deleteByCondition(TClass record){
        return Result.success(tClassService.deleteByCondition(record));
    }

    @RequestMapping("delete")
    @ResponseBody
    public Result<Integer> deleteByPrimaryKey(Integer id){
        return Result.success(tClassService.deleteByPrimaryKey(id));
    }

}
